<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>三次贝塞曲线</title>
</head>
<body>
<canvas id="c1" width="600" height="400" style="border:1px solid #d3d3d3;">
    您的浏览器不支持 HTML5 canvas 标签。
</canvas>
<script>
    var c1 = document.getElementById("c1")
    var ctx = c1.getContext("2d")

    ctx.beginPath()
    ctx.moveTo(300, 200)
    ctx.bezierCurveTo(350, 150, 450, 200, 300, 300)
    ctx.bezierCurveTo(150, 200, 250, 150, 300, 200)
    ctx.stroke()
    ctx.closePath()

    ctx.strokeStyle = 'red';
    ctx.beginPath()
    ctx.moveTo(300, 200)
    ctx.lineTo(350, 150)
    ctx.lineTo(450, 200)
    ctx.lineTo(300, 300)
    ctx.lineTo(150, 200)
    ctx.lineTo(250, 150)
    ctx.lineTo(300, 200)
    ctx.stroke()
    ctx.closePath()
</script>
</body>
</html>
